-- Gearmanager fix.
local function ScrollToIcon()
	local _numItems = 0
	for i = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
		if ( GetInventoryItemTexture("player", i) ) then
			_numItems = _numItems + 1;
		end
	end

	local popup = GearManagerDialogPopup;
	local numIcons = _numItems + GetNumMacroIcons()
	for index=1, numIcons do
		local tex = GetEquipmentSetIconInfo(index) 
		if not tex or tex == "" then
			break
		end
		
		if tex == popup.selectedTexture then
			local btn = mod(index, (NUM_GEARSET_ICONS_SHOWN/NUM_GEARSET_ICON_ROWS))
			local page = floor(index/(NUM_GEARSET_ICONS_SHOWN/NUM_GEARSET_ICON_ROWS))
			if btn == 0 then
				page = page-1
				btn = 5
			end
			GearManagerDialogPopupScrollFrameScrollBar:SetValue((page)*GEARSET_ICON_ROW_HEIGHT)
			FauxScrollFrame_SetOffset(GearManagerDialogPopupScrollFrame, page)
			GearManagerDialogPopup_Update()
			popup.buttons[btn]:Click()
			break
		end
	end
end
GearManagerDialogPopup:HookScript("OnShow", ScrollToIcon)